{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3分钟Python爬取9000张表情包图片"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "本视频的演示步骤：\n",
    "\n",
    "1. 使用requests爬取200个网页\n",
    "2. 使用BeautifulSoup实现图片的标题和地址解析\n",
    "3. 将图片下载到本地目录\n",
    "\n",
    "这2个库的详细用法，请看我的其他视频课程"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "from bs4 import BeautifulSoup\n",
    "import re"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1、下载共200个页面的HTML"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def download_all_htmls():\n",
    "    \"\"\"\n",
    "    下载所有列表页面的HTML，用于后续的分析\n",
    "    \"\"\"\n",
    "    htmls = []\n",
    "    for idx in range(200):\n",
    "        url = f\"https://fabiaoqing.com/biaoqing/lists/page/{idx+1}.html\"\n",
    "        print(\"craw html:\", url)\n",
    "        r = requests.get(url)\n",
    "        if r.status_code != 200:\n",
    "            raise Exception(\"error\")\n",
    "        htmls.append(r.text)\n",
    "    print(\"success\")\n",
    "    return htmls"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/1.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/2.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/3.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/4.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/5.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/6.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/7.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/8.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/9.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/10.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/11.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/12.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/13.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/14.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/15.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/16.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/17.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/18.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/19.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/20.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/21.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/22.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/23.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/24.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/25.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/26.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/27.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/28.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/29.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/30.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/31.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/32.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/33.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/34.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/35.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/36.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/37.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/38.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/39.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/40.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/41.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/42.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/43.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/44.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/45.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/46.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/47.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/48.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/49.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/50.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/51.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/52.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/53.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/54.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/55.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/56.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/57.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/58.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/59.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/60.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/61.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/62.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/63.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/64.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/65.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/66.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/67.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/68.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/69.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/70.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/71.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/72.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/73.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/74.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/75.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/76.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/77.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/78.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/79.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/80.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/81.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/82.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/83.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/84.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/85.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/86.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/87.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/88.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/89.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/90.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/91.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/92.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/93.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/94.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/95.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/96.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/97.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/98.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/99.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/100.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/101.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/102.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/103.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/104.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/105.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/106.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/107.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/108.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/109.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/110.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/111.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/112.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/113.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/114.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/115.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/116.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/117.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/118.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/119.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/120.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/121.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/122.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/123.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/124.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/125.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/126.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/127.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/128.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/129.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/130.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/131.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/132.html\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/133.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/134.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/135.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/136.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/137.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/138.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/139.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/140.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/141.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/142.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/143.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/144.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/145.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/146.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/147.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/148.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/149.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/150.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/151.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/152.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/153.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/154.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/155.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/156.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/157.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/158.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/159.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/160.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/161.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/162.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/163.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/164.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/165.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/166.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/167.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/168.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/169.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/170.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/171.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/172.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/173.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/174.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/175.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/176.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/177.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/178.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/179.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/180.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/181.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/182.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/183.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/184.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/185.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/186.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/187.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/188.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/189.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/190.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/191.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/192.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/193.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/194.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/195.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/196.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/197.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/198.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/199.html\n",
      "craw html: https://fabiaoqing.com/biaoqing/lists/page/200.html\n",
      "success\n"
     ]
    }
   ],
   "source": [
    "# 执行爬取\n",
    "htmls = download_all_htmls()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'<html>\\n\\n<head>\\n    <meta charset=\"UTF-8\">\\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\">\\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\\n    <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\\n    <title>热门表情_发表情，表情包大全fabiaoqing.com</title>\\n    <meta name=\"Keywords\" content=\"热门表情,表情包,聊天表情,微信表情包,QQ表情包,发表情,表情包大全,表情包下载,表情下载,表情包大战,贴吧表情包,表情包集中营,斗图\">\\n    <meta name=\"Description\" content=\"全网热门表情。发表情，最大最全的表情包网站，分享最新最热的表情包、聊天表情、微信表情包、QQ表情包、金馆长表情包、蘑菇头表情包等各类表情。\">\\n    <meta name=\"referrer\" content=\"no-referrer\" />\\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"//lib.baomitu.com/semantic-ui/2.2.2/semantic.min.css\" />\\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"/Public/css/fbq.css?v=2018\" />\\n    <script data-ad-client=\"ca-pub-5486123269162001\" async src=\"https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>\\n    <script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "htmls[0][:1000]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2、解析HTML得到所有的图片标题和URL地址"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def parse_single_html(html):\n",
    "    \"\"\"\n",
    "    解析单个HTML，得到数据\n",
    "    @return list((img_title, img_url))\n",
    "    \"\"\"\n",
    "    soup = BeautifulSoup(html, 'html.parser')\n",
    "    img_divs = soup.find_all(\"div\", class_=\"tagbqppdiv\")\n",
    "    datas = []\n",
    "    for img_div in img_divs:\n",
    "        img_node = img_div.find(\"img\")\n",
    "        if not img_node: continue\n",
    "        datas.append((img_node[\"title\"], img_node[\"data-original\"]))\n",
    "    return datas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[('阿弥陀佛，施主放下骂图，立地成佛！',\n",
      "  'http://ww2.sinaimg.cn/bmiddle/9150e4e5gy1g6qlfb10avj20d70f7gmf.jpg'),\n",
      " ('看见你就烦（草莓果酱ox白眼 GIF 动图表情包）',\n",
      "  'http://wx1.sinaimg.cn/bmiddle/006APoFYly1g68tiftpbmg30bh0bh4o5.gif'),\n",
      " ('我在哭', 'http://wx3.sinaimg.cn/bmiddle/006qir4ogy1g54eoes2q2j309q09cdgh.jpg'),\n",
      " ('我的人生只要这样躺着混日子就很幸福了',\n",
      "  'http://ww4.sinaimg.cn/bmiddle/9150e4e5gy1g6qm7x6fiuj20mw0mmt9y.jpg'),\n",
      " ('草莓果酱ox动图表情包',\n",
      "  'http://wx1.sinaimg.cn/bmiddle/ceeb653ely1g64664qyc0g20bf0br4jn.gif'),\n",
      " ('噗呲 放屁（沙雕羊驼动图表情包）',\n",
      "  'http://wx1.sinaimg.cn/bmiddle/78b88159gy1g69cze2hkkg20bp0bpx0y.gif'),\n",
      " ('来群里转转（熊猫头旋转 GIF 动图）',\n",
      "  'http://wx1.sinaimg.cn/bmiddle/ceeb653ely1g68tzab8xng207608wwou.gif'),\n",
      " ('我爱你（草莓果酱oxGIF 动图表情包）',\n",
      "  'http://wx2.sinaimg.cn/bmiddle/006APoFYly1g68uwg8djlg30b60b6e57.gif'),\n",
      " ('锁屏 带薪拉屎',\n",
      "  'http://wx3.sinaimg.cn/bmiddle/ceeb653ely1g654hwdsjkg20dc0avgm4.gif'),\n",
      " ('我要可爱死你（草莓果酱ox表情包）',\n",
      "  'http://wx2.sinaimg.cn/bmiddle/bf976b12gy1g68hx2gtleg208c08bk8q.gif')]\n"
     ]
    }
   ],
   "source": [
    "import pprint\n",
    "pprint.pprint(parse_single_html(htmls[0])[:10])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 执行所有的HTML页面的解析\n",
    "all_imgs = []\n",
    "for html in htmls:\n",
    "    all_imgs.extend(parse_single_html(html))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('阿弥陀佛，施主放下骂图，立地成佛！',\n",
       "  'http://ww2.sinaimg.cn/bmiddle/9150e4e5gy1g6qlfb10avj20d70f7gmf.jpg'),\n",
       " ('看见你就烦（草莓果酱ox白眼 GIF 动图表情包）',\n",
       "  'http://wx1.sinaimg.cn/bmiddle/006APoFYly1g68tiftpbmg30bh0bh4o5.gif'),\n",
       " ('我在哭', 'http://wx3.sinaimg.cn/bmiddle/006qir4ogy1g54eoes2q2j309q09cdgh.jpg'),\n",
       " ('我的人生只要这样躺着混日子就很幸福了',\n",
       "  'http://ww4.sinaimg.cn/bmiddle/9150e4e5gy1g6qm7x6fiuj20mw0mmt9y.jpg'),\n",
       " ('草莓果酱ox动图表情包',\n",
       "  'http://wx1.sinaimg.cn/bmiddle/ceeb653ely1g64664qyc0g20bf0br4jn.gif'),\n",
       " ('噗呲 放屁（沙雕羊驼动图表情包）',\n",
       "  'http://wx1.sinaimg.cn/bmiddle/78b88159gy1g69cze2hkkg20bp0bpx0y.gif'),\n",
       " ('来群里转转（熊猫头旋转 GIF 动图）',\n",
       "  'http://wx1.sinaimg.cn/bmiddle/ceeb653ely1g68tzab8xng207608wwou.gif'),\n",
       " ('我爱你（草莓果酱oxGIF 动图表情包）',\n",
       "  'http://wx2.sinaimg.cn/bmiddle/006APoFYly1g68uwg8djlg30b60b6e57.gif'),\n",
       " ('锁屏 带薪拉屎',\n",
       "  'http://wx3.sinaimg.cn/bmiddle/ceeb653ely1g654hwdsjkg20dc0avgm4.gif'),\n",
       " ('我要可爱死你（草莓果酱ox表情包）',\n",
       "  'http://wx2.sinaimg.cn/bmiddle/bf976b12gy1g68hx2gtleg208c08bk8q.gif')]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_imgs[:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8999"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(all_imgs)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3、下载图片到本地目录"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 ./output/阿弥陀佛施主放下骂图.jpg\n",
      "1 ./output/看见你就烦草莓果酱o.gif\n",
      "2 ./output/我在哭.jpg\n",
      "3 ./output/我的人生只要这样躺着.jpg\n",
      "4 ./output/草莓果酱ox动图表情.gif\n",
      "5 ./output/噗呲放屁沙雕羊驼动图.gif\n",
      "6 ./output/来群里转转熊猫头旋转.gif\n",
      "7 ./output/我爱你草莓果酱oxG.gif\n",
      "8 ./output/锁屏带薪拉屎.gif\n",
      "9 ./output/我要可爱死你草莓果酱.gif\n",
      "10 ./output/我尼玛傻了都.jpg\n",
      "11 ./output/你今天表现蛮好10分.gif\n",
      "12 ./output/真烦人得找个理由做她.gif\n",
      "13 ./output/哇哦草莓果酱ox表情.jpg\n",
      "14 ./output/哥哥又说笑了乔碧萝表.gif\n",
      "15 ./output/锁屏带薪拉屎.gif\n",
      "16 ./output/我简直难上加难麻将表.jpg\n",
      "17 ./output/滚蛋相亲红包哥表情包.jpg\n",
      "18 ./output/17591800下班.gif\n",
      "19 ./output/乔碧萝听了都想笑斗鱼.jpg\n",
      "20 ./output/四只猪疯狂对视.jpg\n",
      "21 ./output/靓仔敬礼.gif\n",
      "22 ./output/靓女敬礼.gif\n",
      "23 ./output/要不是空气免费我都活.jpg\n",
      "24 ./output/参加公主殿下萌娃黄夏.jpg\n",
      "25 ./output/我就笑笑不说话.gif\n",
      "26 ./output/今大很忙但没有忘记想.gif\n",
      "27 ./output/走去哥哥心里.jpg\n",
      "28 ./output/哈哈哈笑死我啦GIF.gif\n",
      "29 ./output/垃圾分类请问你是什么.gif\n",
      "30 ./output/买西瓜吗买一个大西瓜.gif\n",
      "31 ./output/我太难难南南了.jpg\n",
      "32 ./output/扭起来熊猫头尬舞GI.gif\n",
      "33 ./output/1甲基8乙基二环42.jpg\n",
      "34 ./output/自卑人士.gif\n",
      "35 ./output/撒贝宁疑问问号哈.jpg\n",
      "36 ./output/我给大家开个空调.jpg\n",
      "37 ./output/我拎着开心快乐都掉光.gif\n",
      "38 ./output/以后就叫我敢敢吧一个.jpg\n",
      "39 ./output/快点开车我营养跟得上.gif\n",
      "40 ./output/总感觉你想开车熊猫头.gif\n",
      "41 ./output/你是要讲理还是要我罗.gif\n",
      "42 ./output/我在等你的亲亲噢小新.gif\n",
      "43 ./output/快了已经在做了进度0.jpg\n",
      "44 ./output/没人喜欢我猫咪自拍.jpg\n",
      "45 ./output/那是真的流批.jpg\n",
      "46 ./output/我躲过爱情.gif\n",
      "47 ./output/自以为是波妞我可不是.jpg\n",
      "48 ./output/都是菜鸡何必互啄Ev.jpg\n",
      "49 ./output/我他妈怎么就没有甜甜.jpg\n",
      "50 ./output/望爱情却又得不到爱情.gif\n",
      "51 ./output/杰瑞我们什么时候才能.jpg\n",
      "52 ./output/今晚没有情话只想把你.jpg\n",
      "53 ./output/凡事想想自己配不配.jpg\n",
      "54 ./output/我的小猪猪醒了吗胖虎.jpg\n",
      "55 ./output/想都别想权律二动图表.gif\n",
      "56 ./output/我的小可爱在吗熊猫头.gif\n",
      "57 ./output/都给我闭嘴李现是我的.jpg\n",
      "58 ./output/NMSL键盘怼人表情.jpg\n",
      "59 ./output/垃圾分类从我做起熊猫.jpg\n",
      "60 ./output/拜拜886沙雕羊驼G.gif\n",
      "61 ./output/窝窝头一块钱四个嘿嘿.jpg\n",
      "62 ./output/所以爱会消失对不对罗.jpg\n",
      "63 ./output/我给你科普一下油的种.jpg\n",
      "64 ./output/不聊天请你滚出去别影.gif\n",
      "65 ./output/不爽你打我阿印尼小胖.gif\n",
      "66 ./output/泡面需要三分钟泡你需.jpg\n",
      "67 ./output/呕消防栓漏水.jpg\n",
      "68 ./output/你行咱俩碰碰面看我扎.jpg\n",
      "69 ./output/不要跟我硬碰硬我受的.jpg\n",
      "70 ./output/我太难了流泪熊猫头戴.jpg\n",
      "71 ./output/你看什么呢我请问朋友.jpg\n",
      "72 ./output/mua亲亲罗熙动图表.gif\n",
      "73 ./output/我没有猜错的话现在是.jpg\n",
      "74 ./output/又把大伙搞开心了.jpg\n",
      "75 ./output/你欺负我我要揍你.jpg\n",
      "76 ./output/我是从未来来的求求你.jpg\n",
      "77 ./output/真强啊得找理由跟他混.jpg\n",
      "78 ./output/好我走鸭鸭穿鞋.jpg\n",
      "79 ./output/给爷整笑了.jpg\n",
      "80 ./output/我迈过认真学习练习准.jpg\n",
      "81 ./output/那你很棒哦要我去睡你.gif\n",
      "82 ./output/打个啵儿呀萌娃罗熙动.gif\n",
      "83 ./output/在吗沙雕羊驼.gif\n",
      "84 ./output/我太难了因为我没有钱.jpg\n",
      "85 ./output/姐姐睡定你了.jpg\n",
      "86 ./output/车速太快了小心脏受不.gif\n",
      "87 ./output/熊猫头摆摊表情包窝窝.jpg\n",
      "88 ./output/收到沙雕羊GIF动图.gif\n",
      "89 ./output/此时一名背着武器的侠.jpg\n",
      "90 ./output/让我清醒一下.jpg\n",
      "91 ./output/仔细思考一下大佬在聊.jpg\n",
      "92 ./output/今天很忙但没有忘记想.jpg\n",
      "93 ./output/向黑夜和无所事事的自.jpg\n",
      "94 ./output/韩商言你为什么凶年年.jpg\n",
      "95 ./output/掘强穷人.jpg\n",
      "96 ./output/沙雕网友吊钱没有吊图.jpg\n",
      "97 ./output/熊猫头挑战瓶盖动图.gif\n",
      "98 ./output/你们都睡了吗说好的熬.gif\n",
      "99 ./output/早上好.gif\n",
      "100 ./output/落魄运营在线炒粉10.gif\n",
      "101 ./output/mua亲亲.jpg\n",
      "102 ./output/啦啦啦boom爱心发.gif\n",
      "103 ./output/nmsl那没事了.jpg\n",
      "104 ./output/送你朵花我们和好吧.jpg\n",
      "105 ./output/熊猫头照目前这个形式.jpg\n",
      "106 ./output/不早了一起睡觉吧印尼.gif\n",
      "107 ./output/过来让我亲一下印尼小.gif\n",
      "108 ./output/给你爱情.gif\n",
      "109 ./output/你怎么了我考完了狗子.jpg\n",
      "110 ./output/一个只有高中文化程度.jpg\n",
      "111 ./output/你好你有什么问题都可.gif\n",
      "112 ./output/我干.jpg\n",
      "113 ./output/疑汝飙然无据.jpg\n",
      "114 ./output/问题不大龙妈表情包.jpg\n",
      "115 ./output/气到模糊草莓果酱ox.jpg\n",
      "116 ./output/你不给发红包我怎么帮.jpg\n",
      "117 ./output/小爷路过一下小黄鸭表.jpg\n",
      "118 ./output/匿名网友.gif\n",
      "119 ./output/呲尿小企鹅呲水表情包.jpg\n",
      "120 ./output/你在缩一句似似游乐王.gif\n",
      "121 ./output/此时一位没有钱得JK.jpg\n",
      "122 ./output/我没有生气CNM.jpg\n",
      "123 ./output/有时候真想打你两巴掌.gif\n",
      "124 ./output/想看你床单的颜色.jpg\n",
      "125 ./output/你说女生打游戏菜有什.gif\n",
      "126 ./output/谈恋爱二缺一拒绝我就.jpg\n",
      "127 ./output/我没有生气呀.jpg\n",
      "128 ./output/我不想被劝退我饭卡里.jpg\n",
      "129 ./output/可怜的嗨子看看自己现.jpg\n",
      "130 ./output/你呲不过我小企鹅呲水.jpg\n",
      "131 ./output/我怀疑你在开车但是我.gif\n",
      "132 ./output/大家吃饭了吗没有就自.gif\n",
      "133 ./output/马上写完真的行1列1.jpg\n",
      "134 ./output/你麻痹起来嗨熊猫头表.jpg\n",
      "135 ./output/真可爱得找个机会亲她.jpg\n",
      "136 ./output/我可以这样抱你嘛熊猫.jpg\n",
      "137 ./output/答应我先别嫁好吗在等.gif\n",
      "138 ./output/爷乐意杰尼龟.jpg\n",
      "139 ./output/我能给足你面子也能扇.jpg\n",
      "140 ./output/必须暗鲨小企鹅呲水表.jpg\n",
      "141 ./output/熊猫头长手比心GIF.gif\n",
      "142 ./output/路过.gif\n",
      "143 ./output/参见老婆大人.jpg\n",
      "144 ./output/烷基八氮玩几把蛋.jpg\n",
      "145 ./output/个闪现到你怀里猫咪.jpg\n",
      "146 ./output/提醒拉屎小助手表情包.gif\n",
      "147 ./output/你搞黄色我拍到了.jpg\n",
      "148 ./output/收购快乐.jpg\n",
      "149 ./output/坚持住马上就发工资了.jpg\n",
      "150 ./output/劳资想跟你开开心心玩.jpg\n",
      "151 ./output/落魄美工在线炒粉09.gif\n",
      "152 ./output/在你心里我就是个有害.gif\n",
      "153 ./output/别坐高铁了地球不适合.jpg\n",
      "154 ./output/我从未见过如此好骚之.jpg\n",
      "155 ./output/难搞哦罗熙撩头发.jpg\n",
      "156 ./output/sleepingvs.jpg\n",
      "157 ./output/今天犯点什么坏好呢渣.jpg\n",
      "158 ./output/又把爷搞开心咯.jpg\n",
      "159 ./output/死鬼羞羞啦熊猫头.jpg\n",
      "160 ./output/站住我要打劫你的心.jpg\n",
      "161 ./output/给力奥宁真行整挺好围.jpg\n",
      "162 ./output/你这么可爱忍不住亲你.gif\n",
      "163 ./output/按倒亲.gif\n",
      "164 ./output/youseeseey.jpg\n",
      "165 ./output/再等两天再催我只能自.jpg\n",
      "166 ./output/你这是什么鸡脖意思.jpg\n",
      "167 ./output/心情不是十分美丽.gif\n",
      "168 ./output/给你一个大大的吻权律.gif\n",
      "169 ./output/没有钱我很难帮你办事.jpg\n",
      "170 ./output/我好想打死你啊熊猫头.jpg\n",
      "171 ./output/几百条信息没有一条关.jpg\n",
      "172 ./output/走带你兜兜风妹妹和谐.jpg\n",
      "173 ./output/已读不回罗熙.jpg\n",
      "174 ./output/听到了吗我给你送钟的.jpg\n",
      "175 ./output/混吃等死.jpg\n",
      "176 ./output/拍拍拍死你印尼小胖t.gif\n",
      "177 ./output/给俺也整一个皮卡丘.gif\n",
      "178 ./output/熊猫头抱熊猫头被窝睡.jpg\n",
      "179 ./output/别复习了一起去玩吧.jpg\n",
      "180 ./output/捂嘴笑.gif\n",
      "181 ./output/大家好我是本群的提醒.jpg\n",
      "182 ./output/坏笑四连GIF.gif\n",
      "183 ./output/特别特别特别想你.gif\n",
      "184 ./output/嘴唇干干的好想被滋润.gif\n",
      "185 ./output/如果你嫌我粘人的话那.jpg\n",
      "186 ./output/道理你盗图也该满了3.gif\n",
      "187 ./output/来自老天爷的肯定.gif\n",
      "188 ./output/哈哈哈哈哈爱笑死瓦嘿.gif\n",
      "189 ./output/安静地当个舔狗其他的.jpg\n",
      "190 ./output/几百条消息没有一条关.gif\n",
      "191 ./output/头都整晕了印尼小胖t.gif\n",
      "192 ./output/马上考试了我奔向复习.jpg\n",
      "193 ./output/我很高贵男人没有机会.jpg\n",
      "194 ./output/反正爱情不就那样狗子.jpg\n",
      "195 ./output/够骚我喜欢印尼小胖子.gif\n",
      "196 ./output/脑阔疼脑阔疼印尼小胖.gif\n",
      "197 ./output/沃斯尼蝶我是你爹.jpg\n",
      "198 ./output/拿下我的快乐面具.jpg\n",
      "199 ./output/滚熊猫头.gif\n",
      "200 ./output/就很烦比来大姨妈还烦.jpg\n",
      "201 ./output/OK沙雕羊驼动图表情.gif\n",
      "202 ./output/姐的心禁止访问熊猫头.jpg\n",
      "203 ./output/不屑草莓果酱ox表情.gif\n",
      "204 ./output/人家说你傻逼肯定有人.jpg\n",
      "205 ./output/我太难了giao哥.gif\n",
      "206 ./output/破工作不干了罗文姬.gif\n",
      "207 ./output/呲你小企鹅呲水表情包.gif\n",
      "208 ./output/灵魂六问配钥匙师傅你.jpg\n",
      "209 ./output/群花谁喊我印尼小胖T.gif\n",
      "210 ./output/群帅谁喊我印尼小胖T.gif\n",
      "211 ./output/熊猫头吹泡泡GIF动.gif\n",
      "212 ./output/没救了送火葬场吧熊猫.jpg\n",
      "213 ./output/没有夜宵真的快乐不起.jpg\n",
      "214 ./output/花钱一时爽一直花钱一.jpg\n",
      "215 ./output/你过来我有恋爱想跟你.gif\n",
      "216 ./output/我扎心摸仙要和你讨论.jpg\n",
      "217 ./output/本人朋友圈已安装空调.jpg\n",
      "218 ./output/疯狂记仇印尼小胖子t.gif\n",
      "219 ./output/这人真蔡.jpg\n",
      "220 ./output/在吗出来谈恋爱.jpg\n",
      "221 ./output/可爱的我出现了.gif\n",
      "222 ./output/啥破群连个勾搭我的都.gif\n",
      "223 ./output/你在质疑我明言明语黄.jpg\n",
      "224 ./output/妙手仁心吴启华你说的.gif\n",
      "225 ./output/大兄弟你村断网了是吧.jpg\n",
      "226 ./output/不用管我我就进来看看.gif\n",
      "227 ./output/清早起床打开窗心情美.gif\n",
      "228 ./output/单纯的我把一切都写在.jpg\n",
      "229 ./output/就是他吗的扛不住哇杰.jpg\n",
      "230 ./output/不行除非你亲我一下熊.gif\n",
      "231 ./output/印尼小胖tatan托.gif\n",
      "232 ./output/下班咯开冲.jpg\n",
      "233 ./output/被生活的重担压得喘不.jpg\n",
      "234 ./output/想到你我就很开心印尼.gif\n",
      "235 ./output/真是极端暴躁老哥啊.jpg\n",
      "236 ./output/扎起我的高马尾我还能.jpg\n",
      "237 ./output/弟弟你说话真招笑.gif\n",
      "238 ./output/biu对你爱心发送萌.gif\n",
      "239 ./output/我盯上你的时候是福是.gif\n",
      "240 ./output/我发现这里有搞事的袋.jpg\n",
      "241 ./output/您的小宝贝已生气请亲.jpg\n",
      "242 ./output/请赐我甜甜的恋爱.gif\n",
      "243 ./output/呲尿.gif\n",
      "244 ./output/我的小鱼塘为什么没有.gif\n",
      "245 ./output/吻我一下好吗熊猫头.jpg\n",
      "246 ./output/日常看群萌娃阿布莱提.gif\n",
      "247 ./output/我看你就是个神经病.gif\n",
      "248 ./output/我想把你给撕了乡村爱.jpg\n",
      "249 ./output/我尽量哭的很小声猫和.jpg\n",
      "250 ./output/滑稽鸡玩滑板.jpg\n",
      "251 ./output/要记得想我哦印尼小胖.gif\n",
      "252 ./output/夜生活才刚刚开始艾瑞.gif\n",
      "253 ./output/哈哈哈不要再逗大伙笑.jpg\n",
      "254 ./output/暴富脱单别打扰我做白.gif\n",
      "255 ./output/安静地当个舔狗其他的.jpg\n",
      "256 ./output/小委屈小伤感.jpg\n",
      "257 ./output/狙击你的心游乐王子表.jpg\n",
      "258 ./output/谁又在迫害我游ne娃.gif\n",
      "259 ./output/滚开变态熊猫头.gif\n",
      "260 ./output/醒醒吧你水枪滋醒你.jpg\n",
      "261 ./output/死了算了.jpg\n",
      "262 ./output/不要跟我硬碰硬我受的.jpg\n",
      "263 ./output/我怀疑你有病但是我没.gif\n",
      "264 ./output/拿放大镜也看不透你个.gif\n",
      "265 ./output/我是一只小绵羊你可以.jpg\n",
      "266 ./output/大家好我是本群的提醒.gif\n",
      "267 ./output/晚安沙雕羊驼.gif\n",
      "268 ./output/帅气男人的肯定熊猫头.jpg\n",
      "269 ./output/群宠熊猫头打伞表情包.jpg\n",
      "270 ./output/小熊猫朝你比了个中指.jpg\n",
      "271 ./output/唐僧肉烤肉徒儿你这是.jpg\n",
      "272 ./output/熊猫头涉黄人士.jpg\n",
      "273 ./output/熊猫头吓到自己GIF.gif\n",
      "274 ./output/给你比心心李现动图表.gif\n",
      "275 ./output/李现式疑惑.jpg\n",
      "276 ./output/原来你们都会私底下加.jpg\n",
      "277 ./output/发出杠铃般的笑声武林.gif\n",
      "278 ./output/原本我是憨憨遇到你我.gif\n",
      "279 ./output/我就是这个脾气.jpg\n",
      "280 ./output/我除了跪还能做什么熊.jpg\n",
      "281 ./output/别跟我再说这些肉麻的.gif\n",
      "282 ./output/我本不想流泪但寂寞的.jpg\n",
      "283 ./output/再你妈的见.gif\n",
      "284 ./output/我根本不想和你吵架我.jpg\n",
      "285 ./output/请问你挂什么科挂科表.jpg\n",
      "286 ./output/我只想做个与世无争的.jpg\n",
      "287 ./output/想不想尝尝我的拳头嚯.gif\n",
      "288 ./output/想问为什么我不再是你.jpg\n",
      "289 ./output/把爷逗乐了.gif\n",
      "290 ./output/可怜的嗨子看看自己现.gif\n",
      "291 ./output/雨女无瓜萌娃黄夏温h.jpg\n",
      "292 ./output/我感觉你不需要脑子.jpg\n",
      "293 ./output/有本事冲这来一拳印尼.gif\n",
      "294 ./output/雨女无瓜熊猫头与你无.jpg\n",
      "295 ./output/是是心动的感觉.jpg\n",
      "296 ./output/这话我不爱听给我撤回.gif\n",
      "297 ./output/小雪糕都不买你有什么.jpg\n",
      "298 ./output/哈哈哈哈哈笑死人啦罗.gif\n",
      "299 ./output/这么关注我爱豆你爱豆.jpg\n",
      "300 ./output/晚安我已经安排了会有.jpg\n",
      "301 ./output/姐妹同心其利断金大妈.jpg\n",
      "302 ./output/okok小手ok动图.gif\n",
      "303 ./output/要记得想我哦印尼小胖.gif\n",
      "304 ./output/人家求你了嘛罗熙.jpg\n",
      "305 ./output/我想对你说滚印尼小胖.gif\n",
      "306 ./output/今天除了打游戏又啥也.jpg\n",
      "307 ./output/丢砖头GIF动图.gif\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "308 ./output/你们要买西瓜吗买一送.jpg\n",
      "309 ./output/你很过分啊你印尼小胖.gif\n",
      "310 ./output/我信号圈外面没信号就.gif\n",
      "311 ./output/我怀疑你在开车但我没.jpg\n",
      "312 ./output/早安沙雕羊驼.gif\n",
      "313 ./output/火车票机票酒店你觉得.jpg\n",
      "314 ./output/睡觉吧狗命最重要.jpg\n",
      "315 ./output/我好烦想饮酒.jpg\n",
      "316 ./output/悲伤爆炸谁也安慰不了.jpg\n",
      "317 ./output/忙碌的日子照顾好自己.gif\n",
      "318 ./output/打球吗我不菜药酱药水.jpg\n",
      "319 ./output/自带爱你的光芒印尼小.gif\n",
      "320 ./output/你可以对我指点但不能.gif\n",
      "321 ./output/抱紧我的猪宝贝.gif\n",
      "322 ./output/偷偷亲你萌娃罗熙动图.gif\n",
      "323 ./output/我太累了没办法扇你你.jpg\n",
      "324 ./output/老戴里都是你罗熙表情.jpg\n",
      "325 ./output/复习不完了.jpg\n",
      "326 ./output/喂来份夜宵熬夜的人应.gif\n",
      "327 ./output/说你到底是干了没有.gif\n",
      "328 ./output/谁又在迫害我游ne娃.jpg\n",
      "329 ./output/悲伤爆炸谁也安慰不了.jpg\n",
      "330 ./output/人可以休息灵魂还要耍.jpg\n",
      "331 ./output/我希望你做个甜甜的梦.jpg\n",
      "332 ./output/来了来了萌娃黄夏温h.jpg\n",
      "333 ./output/戴好没有快点鸭鸭表情.jpg\n",
      "334 ./output/滚印尼小胖TATAN.gif\n",
      "335 ./output/在吗出来挨打.jpg\n",
      "336 ./output/我怀疑你有病但是我没.jpg\n",
      "337 ./output/有车别藏着掖着啊都开.gif\n",
      "338 ./output/一天除了骚啥也没干美.jpg\n",
      "339 ./output/讲不通的不如直接开骂.jpg\n",
      "340 ./output/老公宝贝哥哥亲爱的男.gif\n",
      "341 ./output/狗子歪头问号表情包.jpg\n",
      "342 ./output/笑到肚子疼.gif\n",
      "343 ./output/你现在知错已经太晚了.jpg\n",
      "344 ./output/这人傻逼吧印尼小胖T.gif\n",
      "345 ./output/又开始了是吧.gif\n",
      "346 ./output/音量我哭得好大声.jpg\n",
      "347 ./output/你好坏哦印尼小胖TA.gif\n",
      "348 ./output/1000多人在线的群.jpg\n",
      "349 ./output/难道我错了吗药酱药水.gif\n",
      "350 ./output/整天沉迷厕所WC.jpg\n",
      "351 ./output/MUA给你个大大的飞.gif\n",
      "352 ./output/鸡掰人印尼小胖TAT.gif\n",
      "353 ./output/请赐我甜甜的恋爱.gif\n",
      "354 ./output/我说老奶奶你坐稳了我.jpg\n",
      "355 ./output/每日被惹生气次数正正.jpg\n",
      "356 ./output/我的手头有点紧.jpg\n",
      "357 ./output/沙雕熊猫头托眼镜.jpg\n",
      "358 ./output/打趴你印尼小胖TAT.gif\n",
      "359 ./output/谁是傻逼我心里有数你.gif\n",
      "360 ./output/睡觉吧狗命最重要.jpg\n",
      "361 ./output/在亲个嘴.jpg\n",
      "362 ./output/得意忘形.jpg\n",
      "363 ./output/你是我的鸭猫和老鼠.jpg\n",
      "364 ./output/药酱药水哥指人警告表.gif\n",
      "365 ./output/要老公抱.jpg\n",
      "366 ./output/药酱药水哥亲亲动图.gif\n",
      "367 ./output/你gay我走远一爹巴.jpg\n",
      "368 ./output/有点东西熊猫头.jpg\n",
      "369 ./output/你怎么回事老婆.jpg\n",
      "370 ./output/不聊天请你滚出去别影.gif\n",
      "371 ./output/今天也没什么干劲明天.jpg\n",
      "372 ./output/看见没老子爱你熊猫头.gif\n",
      "373 ./output/什嘤嘤嘤大坏蛋小拳拳.jpg\n",
      "374 ./output/兄弟们来了.gif\n",
      "375 ./output/蔡得不敢吱声.gif\n",
      "376 ./output/疑车无据.jpg\n",
      "377 ./output/又开始了是吗吴京表情.jpg\n",
      "378 ./output/老司机这两天风声紧管.jpg\n",
      "379 ./output/这边滚不送.gif\n",
      "380 ./output/给你打一针退骚针动图.gif\n",
      "381 ./output/亲一口.gif\n",
      "382 ./output/太泪了.jpg\n",
      "383 ./output/亲这边建议您网恋选我.gif\n",
      "384 ./output/落魄美工在线炒粉09.gif\n",
      "385 ./output/宁是个撒贝吧.jpg\n",
      "386 ./output/寻找归宿有害垃圾.jpg\n",
      "387 ./output/经理又他妈开机混底薪.jpg\n",
      "388 ./output/嫁给我吧借款养你.jpg\n",
      "389 ./output/你俩私聊吧我吃醋啦熊.jpg\n",
      "390 ./output/老公亲亲.gif\n",
      "391 ./output/你还敢和我刘波做对吗.jpg\n",
      "392 ./output/儿砸你开心就好.jpg\n",
      "393 ./output/说想我快点印尼小胖T.gif\n",
      "394 ./output/四火又做绰了什么似么.gif\n",
      "395 ./output/老铁我载你去兜轰呐.gif\n",
      "396 ./output/是爱情吗怎么有酸臭味.jpg\n",
      "397 ./output/卧槽差点笑出声麻痹忍.gif\n",
      "398 ./output/当场气死.gif\n",
      "399 ./output/怀疑你无照驾驶请出示.jpg\n",
      "400 ./output/来打我啊我有医保我怕.gif\n",
      "401 ./output/一定等我等我出去.jpg\n",
      "402 ./output/锦鲤转运.gif\n",
      "403 ./output/别说话听他们吹.jpg\n",
      "404 ./output/你继续说我在听.jpg\n",
      "405 ./output/咱也不知道咱也不敢问.jpg\n",
      "406 ./output/好嗨哟感觉人生已经到.gif\n",
      "407 ./output/我好委屈喔罗熙.gif\n",
      "408 ./output/我常因为不够变态而和.jpg\n",
      "409 ./output/看见没有除了我全是有.jpg\n",
      "410 ./output/我只是一个沉默寡言善.gif\n",
      "411 ./output/干嘛呀我都害羞了.jpg\n",
      "412 ./output/上游戏.jpg\n",
      "413 ./output/爱宁药酱药水哥.jpg\n",
      "414 ./output/出来出来药酱药水哥.gif\n",
      "415 ./output/请你滚出微信.gif\n",
      "416 ./output/大家好我是本群的提醒.gif\n",
      "417 ./output/快说你喜欢我然后我们.gif\n",
      "418 ./output/我一直以为聊天就可以.jpg\n",
      "419 ./output/魔仙们的鄙视.jpg\n",
      "420 ./output/皮卡皮卡皮雷佳音co.jpg\n",
      "421 ./output/买西瓜吗买一个大西瓜.jpg\n",
      "422 ./output/等一个富婆通讯录.jpg\n",
      "423 ./output/这他妈的是什么人间疾.jpg\n",
      "424 ./output/求求你了我这辈子第一.jpg\n",
      "425 ./output/真羡慕你有我这么可爱.gif\n",
      "426 ./output/嘴巴发射爱心GIF动.gif\n",
      "427 ./output/瞪听听这是人说的话吗.gif\n",
      "428 ./output/太给力了兄弟派大星表.jpg\n",
      "429 ./output/拜托拜托猫咪GIF动.gif\n",
      "430 ./output/真是极端暴躁老哥啊.jpg\n",
      "431 ./output/你们怎么不说话了都是.jpg\n",
      "432 ./output/熊猫头吹泡泡动图.gif\n",
      "433 ./output/你的酒馆对我打了烊.jpg\n",
      "434 ./output/奇怪了怎么还没开车.jpg\n",
      "435 ./output/我想亲你的小嘴嘴熊猫.jpg\n",
      "436 ./output/烦了勿扰猫咪.jpg\n",
      "437 ./output/朋友你最近怎么样我焦.jpg\n",
      "438 ./output/今天几点开车啊.gif\n",
      "439 ./output/爸爸的事你少管熊猫头.gif\n",
      "440 ./output/昂憨b一个罢了.jpg\n",
      "441 ./output/说晚安吧我要睡了.gif\n",
      "442 ./output/侧目微笑默叹以为妙绝.jpg\n",
      "443 ./output/老公老公要抱抱印尼小.gif\n",
      "444 ./output/你的层次太低了爹游乐.gif\n",
      "445 ./output/你想通了吧.jpg\n",
      "446 ./output/你又在搞黄色熊猫头.gif\n",
      "447 ./output/爷歇逼了皮卡丘.jpg\n",
      "448 ./output/你这个沙雕笑死我了印.gif\n",
      "449 ./output/在路上马上到.jpg\n",
      "450 ./output/我拍到你搞黄色的证据.jpg\n",
      "451 ./output/钱赚不到仔泡不到活着.jpg\n",
      "452 ./output/印尼小胖TATAN发.gif\n",
      "453 ./output/堵住你的嘴亲吻表情包.jpg\n",
      "454 ./output/mua萌娃亲亲动图表.gif\n",
      "455 ./output/我想在你耳边唱一整晚.gif\n",
      "456 ./output/照目前这个形势来看我.jpg\n",
      "457 ./output/你这么骚一定是个湿垃.gif\n",
      "458 ./output/变脸样蹦哒GIF动图.gif\n",
      "459 ./output/没有钱我很难帮你办事.jpg\n",
      "460 ./output/让我看看是谁没有垃圾.jpg\n",
      "461 ./output/虽然这题我不会但也不.jpg\n",
      "462 ./output/乖乖把药吃了别再发疯.gif\n",
      "463 ./output/破群迟早要完.jpg\n",
      "464 ./output/上车前上车后强壮.jpg\n",
      "465 ./output/气的我心脏疼印尼小胖.gif\n",
      "466 ./output/再您妈的见.gif\n",
      "467 ./output/差不多行了搞清自己的.jpg\n",
      "468 ./output/360度无死角暴躁.jpg\n",
      "469 ./output/想在帅帅的小哥哥怀里.gif\n",
      "470 ./output/想做你枕边书怀中猫意.gif\n",
      "471 ./output/真可爱啊幸好是属于我.gif\n",
      "472 ./output/mua送你个超大么么.gif\n",
      "473 ./output/提醒喝水小助手大家好.jpg\n",
      "474 ./output/满眼都是你猪头印尼小.gif\n",
      "475 ./output/快乐地跳起了探戈.jpg\n",
      "476 ./output/印尼小胖TATAN火.gif\n",
      "477 ./output/要不咱俩亲个嘴缓解一.jpg\n",
      "478 ./output/今天除了皮又啥也没干.jpg\n",
      "479 ./output/他妈的罗熙动图表情包.gif\n",
      "480 ./output/挑逗的眼神印尼小胖T.gif\n",
      "481 ./output/记仇疯狂记仇好感1.jpg\n",
      "482 ./output/有趣实在有趣.gif\n",
      "483 ./output/把老娘的衣柜放下然后.jpg\n",
      "484 ./output/我是一个没有感情的挂.jpg\n",
      "485 ./output/你气我这个摸仙.jpg\n",
      "486 ./output/我爱你是肯定的只爱你.jpg\n",
      "487 ./output/奶茶喝一喝生活乐趣多.jpg\n",
      "488 ./output/水泥己到告辞.jpg\n",
      "489 ./output/萌妹落泪.gif\n",
      "490 ./output/熊猫头偷看.jpg\n",
      "491 ./output/Tipstudyun.jpg\n",
      "492 ./output/痴迷.jpg\n",
      "493 ./output/内容引趣不适已举报.jpg\n",
      "494 ./output/你喜欢老子吗.jpg\n",
      "495 ./output/给大佬倒橙汁.gif\n",
      "496 ./output/只有我哭才能引起你的.jpg\n",
      "497 ./output/点头如捣蒜猫咪.gif\n",
      "498 ./output/你永远呲不醒一个张着.jpg\n",
      "499 ./output/趁老子还没有变孙悟空.gif\n",
      "500 ./output/小小的眼睛里有大大的.jpg\n",
      "501 ./output/你是不是在搞黄色.gif\n",
      "502 ./output/东方不亮西方亮憨批啥.jpg\n",
      "503 ./output/亲爱的好想吻你吃你的.gif\n",
      "504 ./output/在哪里老子放假了.jpg\n",
      "505 ./output/弟弟你可往后稍稍.gif\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-10-2cdd2d16683a>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m     12\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     13\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0midx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfilename\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 14\u001b[1;33m     \u001b[0mimg_data\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrequests\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mimg_url\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     15\u001b[0m     \u001b[1;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfilename\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m\"wb\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     16\u001b[0m         \u001b[0mf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwrite\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mimg_data\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcontent\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32md:\\appdata\\python37\\lib\\site-packages\\requests\\api.py\u001b[0m in \u001b[0;36mget\u001b[1;34m(url, params, **kwargs)\u001b[0m\n\u001b[0;32m     73\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     74\u001b[0m     \u001b[0mkwargs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msetdefault\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'allow_redirects'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 75\u001b[1;33m     \u001b[1;32mreturn\u001b[0m \u001b[0mrequest\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'get'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0murl\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mparams\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mparams\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     76\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     77\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32md:\\appdata\\python37\\lib\\site-packages\\requests\\api.py\u001b[0m in \u001b[0;36mrequest\u001b[1;34m(method, url, **kwargs)\u001b[0m\n\u001b[0;32m     58\u001b[0m     \u001b[1;31m# cases, and look like a memory leak in others.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     59\u001b[0m     \u001b[1;32mwith\u001b[0m \u001b[0msessions\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mSession\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0msession\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 60\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0msession\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrequest\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmethod\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0murl\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0murl\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     61\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     62\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32md:\\appdata\\python37\\lib\\site-packages\\requests\\sessions.py\u001b[0m in \u001b[0;36mrequest\u001b[1;34m(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)\u001b[0m\n\u001b[0;32m    531\u001b[0m         }\n\u001b[0;32m    532\u001b[0m         \u001b[0msend_kwargs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mupdate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msettings\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 533\u001b[1;33m         \u001b[0mresp\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mprep\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0msend_kwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    534\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    535\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mresp\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32md:\\appdata\\python37\\lib\\site-packages\\requests\\sessions.py\u001b[0m in \u001b[0;36msend\u001b[1;34m(self, request, **kwargs)\u001b[0m\n\u001b[0;32m    684\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    685\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mstream\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 686\u001b[1;33m             \u001b[0mr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcontent\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    687\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    688\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mr\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32md:\\appdata\\python37\\lib\\site-packages\\requests\\models.py\u001b[0m in \u001b[0;36mcontent\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m    826\u001b[0m                 \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_content\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    827\u001b[0m             \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 828\u001b[1;33m                 \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_content\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34mb''\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0miter_content\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mCONTENT_CHUNK_SIZE\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mor\u001b[0m \u001b[1;34mb''\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    829\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    830\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_content_consumed\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32md:\\appdata\\python37\\lib\\site-packages\\requests\\models.py\u001b[0m in \u001b[0;36mgenerate\u001b[1;34m()\u001b[0m\n\u001b[0;32m    748\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mhasattr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mraw\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'stream'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    749\u001b[0m                 \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 750\u001b[1;33m                     \u001b[1;32mfor\u001b[0m \u001b[0mchunk\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mraw\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstream\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mchunk_size\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdecode_content\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    751\u001b[0m                         \u001b[1;32myield\u001b[0m \u001b[0mchunk\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    752\u001b[0m                 \u001b[1;32mexcept\u001b[0m \u001b[0mProtocolError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32md:\\appdata\\python37\\lib\\site-packages\\urllib3\\response.py\u001b[0m in \u001b[0;36mstream\u001b[1;34m(self, amt, decode_content)\u001b[0m\n\u001b[0;32m    529\u001b[0m         \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    530\u001b[0m             \u001b[1;32mwhile\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mis_fp_closed\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_fp\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 531\u001b[1;33m                 \u001b[0mdata\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mamt\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mamt\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdecode_content\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mdecode_content\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    532\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    533\u001b[0m                 \u001b[1;32mif\u001b[0m \u001b[0mdata\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32md:\\appdata\\python37\\lib\\site-packages\\urllib3\\response.py\u001b[0m in \u001b[0;36mread\u001b[1;34m(self, amt, decode_content, cache_content)\u001b[0m\n\u001b[0;32m    477\u001b[0m             \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    478\u001b[0m                 \u001b[0mcache_content\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mFalse\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 479\u001b[1;33m                 \u001b[0mdata\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_fp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mamt\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    480\u001b[0m                 \u001b[1;32mif\u001b[0m \u001b[0mamt\u001b[0m \u001b[1;33m!=\u001b[0m \u001b[1;36m0\u001b[0m \u001b[1;32mand\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mdata\u001b[0m\u001b[1;33m:\u001b[0m  \u001b[1;31m# Platform-specific: Buggy versions of Python.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    481\u001b[0m                     \u001b[1;31m# Close the connection when no data is returned\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32md:\\appdata\\python37\\lib\\http\\client.py\u001b[0m in \u001b[0;36mread\u001b[1;34m(self, amt)\u001b[0m\n\u001b[0;32m    455\u001b[0m             \u001b[1;31m# Amount is given, implement using readinto\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    456\u001b[0m             \u001b[0mb\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mbytearray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mamt\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 457\u001b[1;33m             \u001b[0mn\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreadinto\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    458\u001b[0m             \u001b[1;32mreturn\u001b[0m \u001b[0mmemoryview\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[0mn\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtobytes\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    459\u001b[0m         \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32md:\\appdata\\python37\\lib\\http\\client.py\u001b[0m in \u001b[0;36mreadinto\u001b[1;34m(self, b)\u001b[0m\n\u001b[0;32m    499\u001b[0m         \u001b[1;31m# connection, and the user is reading more bytes than will be provided\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    500\u001b[0m         \u001b[1;31m# (for example, reading in 1k chunks)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 501\u001b[1;33m         \u001b[0mn\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreadinto\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    502\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mn\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    503\u001b[0m             \u001b[1;31m# Ideally, we would raise IncompleteRead if the content-length\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32md:\\appdata\\python37\\lib\\socket.py\u001b[0m in \u001b[0;36mreadinto\u001b[1;34m(self, b)\u001b[0m\n\u001b[0;32m    587\u001b[0m         \u001b[1;32mwhile\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    588\u001b[0m             \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 589\u001b[1;33m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_sock\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrecv_into\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    590\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    591\u001b[0m                 \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_timeout_occurred\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "for idx, (title, img_url) in enumerate(all_imgs):\n",
    "    # 移除标点符号，只保留中文、大小写字母和阿拉伯数字\n",
    "    reg = \"[^0-9A-Za-z\\u4e00-\\u9fa5]\"\n",
    "    title = re.sub(reg, '', title)\n",
    "    \n",
    "    # 发现了超长的图片标题，做截断\n",
    "    if len(title)>10: title = title[:10]\n",
    "    \n",
    "    # 得到jpg还是gif后缀\n",
    "    post_fix = img_url[-3:]\n",
    "    filename = f\"./output/{title}.{post_fix}\"\n",
    "    \n",
    "    print(idx, filename)\n",
    "    img_data = requests.get(img_url)\n",
    "    with open(filename,\"wb\")as f:\n",
    "        f.write(img_data.content)\n",
    "\n",
    "print(\"success\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
